The KCL compiler translates a Lisp program stored in a source file into a C-language program, invokes the C-language compiler to compile the C-language program, and then generates an object file, called fasl file (or o-file because of the actual filetype). The compiled program in a fasl file is loaded by the function load.
Ordinarily, the object program generated by the KCL compiler scarcely does runtime error-checking for runtime efficiency. In addition, Lisp functions in the same source file are linked together and some system functions are open-coded in-line. To control runtime error checking, supply appropriate optimize declarations (see Section 7.1).
The KCL compiler processes the eval-when special form exactly as specified in the Common Lisp Reference Manual. However, all top-level forms in the source file are normally processed in compile-time-too mode, not in not-compile-time mode (see Section 5.3.3 of the Common Lisp Reference Manual). That is, each top-level form top-level-form is processed as if it were surrounded by the eval-when special form with the situations compile, load, and eval.
(eval-when (compile load eval) top-level-form)
There is no exception for this rule. Thus, for instance, in the example of set-macro-character form in Section 5.3.3 of the Common Lisp Reference Manual, the surrounding eval-when form is unnecessary in KCL. If it is desired that each top-level form be processed in not-compile-time mode, change the value of the KCL specific variable *eval-when-compile* as described below.
The KCL compiler is invoked by the functions compile-file, compile, and disassemble described below. In addition, the KCL compiler may be invoked directly by the Shell commands lc or lc1. These commands require the file name of the source file as their argument. Both lc and lc1 simply add ``.lsp'' to the file name argument to obtain the full name of the source file.
% lc filename
has the same effect as the compiler invocation (compile-file ``filename'') from within KCL, and
% lc1 filename
has the same effects as (compile-file ``filename'' :o-file t :c-file t :h-file t :data-file t).
compile-file input-pathname[Function]
compile-file compiles the Lisp program stored in the file specified by input-pathname, and generates a fasl file. Also compile-file generates the following temporary files.
Temporary File | Contents | |
c-file | C version of the Lisp program | |
h-file | The include file referenced in the c-file | |
data-file | The Lisp data to be used at load time |
If files of these names already exist, the old files will be deleted first. Usually, these intermediate files are automatically deleted after execution of compile-file.
The input-file is determined in the usual manner (see Section 2.9), except that, if the filetype is not specified, then the default filetype .lsp will be used. The keyword parameter :output-file defines the default directory and the default name to be applied to the output files (i.e., the fasl file and the temporary files). :output-file itself defaults to input-pathname. That is, if :output-file is not supplied, then the directory and the name of the input file will be used as the default directory and the default name for the output files. The filetypes of the output files are fixed as follows.
Output File | Filetype | |
fasl file | .o | |
c-file | .c | |
h-file | .h | |
data-file | .data |
Each output file can be specified by the corresponding keyword parameter. If the value of the keyword parameter is nil, then the output file will be deleted after execution of compile-file. If the value of the keyword parameter is t, then the output file will be left in the default directory under the default name. Otherwise, the output file will be left in the directory under the name specified by the keyword parameter. The default value of :o-file is t , and the default values of :c-file, :h-file, and :data-file are all nil.
Example:
(compile-file 'foo)
(compile-file 'foo.lish)
(compile-file ``/usr/mas/foo'' :output-file ``/usr/tai/baa'')
The compiler of KCL/AOS generates the following output files.
Output File | Filetype | Contents | |
fasl file | .fasl | The fasl file | |
c-file | .c | C version of the Lisp program | |
h-file | .h | The include file referenced in the c-file | |
ob-file | .ob | The object file generated by the C compiler | |
data-file | .data | The Lisp data to be used at load time |
Note that the filetype of the fasl file is .fasl in KCL/AOS. Also note that the compiler of KCL/AOS generates an additional file ob-file. Accordingly, the function compile-file has a slightly different definition:
compile-file input-pathname[Function]
The keyword parameter :fasl-file corresponds to the keyword parameter :o-file in KCL on Unix. In particular, the default value of :fasl-file is t and the default values of :c-file, :h-file, :ob-file, and :data-file are all nil. In KCL/AOS,
) lc1 filename
has the same effects as (compile-file ``filename'' :fasl-file t :c-file t :h-file t :ob-file t :data-file t).
Because KCL/AOS follows the convention of the AOS/VS file system, the last example above should be replaced as:
( compile-file ``:udd:mas:foo'' :output-file ``:udd:tai:baa'')
compile name &optional definition[Function]
disassemble &optional thing &key :h-file :data-file
[Function]
eval-when-compile*[Variable]